package wyq.gy.fragment;


import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.SaveCallback;

import wyq.gy.Bean.robOrderMsg;
import wyq.gy.MainActivity;
import wyq.gy.R;
import wyq.gy.ReleaseOrderActivity;

public class TipsDialogFragment extends DialogFragment {
    private static String TAG = "TipsDialogFragment";

    public TipsDialogFragment() {
    }


    @Override
    public void onStart() {
        super.onStart();
        // 设置dialog的layout
        DisplayMetrics dm = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
        WindowManager.LayoutParams layoutParams = getDialog().getWindow().getAttributes();
        layoutParams.width = dm.widthPixels;
        layoutParams.height = layoutParams.WRAP_CONTENT;
        layoutParams.gravity = Gravity.CENTER;
        getDialog().getWindow().setAttributes(layoutParams);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_dialog_tips, container, false);

        Button acceptBtn = (Button)view.findViewById(R.id.accept_btn);
        acceptBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();;
                Intent intent = new Intent();
                intent.setClass(getActivity(), ReleaseOrderActivity.class);
                startActivity(intent);
            }
        });
        Button forbidBtn = (Button)view.findViewById(R.id.forbid_btn);
        forbidBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        return view;
    }


    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Dialog dialog = super.onCreateDialog(savedInstanceState);//设置actionbar的隐藏
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);


        return dialog;
    }
}
